CSE 1325 – Spring 2014

Object-Oriented and Event-driven Programming in Java

Lab 4

 

Design Document Due Date:      Tuesday, May  6, 2014 at 11:59pm  -- This is during finals week

                                                                                    (one minute before midnight 12am)

Lab Due Date:                              Thursday, May 8, 2014 at 11:59pm  -- This is during finals week

(see instructions on website for how to turn this in - Òlab submission infoÓ)

Extra Credit for Early Submission: 

            All required elements of Lab #4 submitted by Sunday, May 4, 2014 at 11:59pm : 20 points extra credit

All required elements of Lab #4 submitted by Monday, May 5, 2014 at 11:59pm : 15 points extra credit

All required elements of Lab #4 submitted by Tuesday, May 6, 2014 at 11:59pm : 10 points extra credit

All required elements of Lab #4 submitted by Wednesday, May 7, 2014 at 11:59pm : 5 points extra credit

NO LATE LABS ACCEPTED for Lab #4.

 

Grade value:  11% out of 100% for all grades  (original value)

Revised grade values for labs:         Lab #1 – 5% out of 100%

                                                            Lab #2 – 11% out of 100%

                                                            Lab #3 – 15% out of 100%

                                                            Lab #4 – 15% out of 100%

           

Objective:

The theme of this project is to design classes and methods for managing a community theater (plays, directors, actors, attendees) using object-oriented design (OOD) principles. This project builds on the previous labs as will the rest of the projects in the semester. Please make sure you adhere to OO principles throughout the design and implementation. The projects are designed to give you an opportunity to exercise the principles taught in the course. Remember, Java is only a vehicle for supporting OOD. Make sure you fully leverage the features available in Java for your benefit as long as weÕve touched on them in class.  Ask before jumping into totally new concepts for your lab.

 

In this project, you will be designing the data abstractions and required operations on those abstractions for managing a community theater.

 

Be sure to check the DEDUCTIONS section at the end of this assignment to avoid penalties

 

You are also required to design your program in advance before you begin writing code.  You will document your design and turn in the design document at least a week before the lab assignment is due.  The goal of the design document is to assist you in developing the actual program.   Note SHORTER time between design and lab due dates.

 

 

Description:

Design classes, fields (attributes) and methods for the problem description below. Make sure you understand and differentiate between public and private ( and optionally protected) fields and methods. Use static fields/methods where appropriate. Make sure each class has at least one constructor (more as needed) with arguments. Each class should have appropriate get (accessor) and set (mutator) methods. Each class should have a toString method (and other formatting methods as needed).

 

Use a ÒtestÓ class to run the application (to test/call each method defined in classes). The test class should ask for and accept user input, print the following menu, and execute the menu to provide understandable output. All inputs (as appropriate for the menu) should be accepted from the user as specified (files, GUIs,  or keyboard input) and should prompt for the input with appropriate messages. If bounds are appropriate, please indicate it in the prompt and check for input errors. Test your source code—be sure every method works correctly.

 

For Lab #4 you will see additional requirements below

 

Test class main routine should check all of the following.  This means that each element below is considered a test case for your classes:

1) Sell tickets to attendees for a specific seat at a specific showing of a play

2) Rent items for the play

3) Hire an actor or director – add them to the payroll.

4) Pay an actor/director  -  see details below for payment methods

5) Remove (fire) an actor /director

6) Display all actor/director details 

7) Display all attendee details (including name, date to attend, seats)

8) Display all play details (all shows, all actors and directors)

9) Display all show details (date, day, and time, all seats (box and regular), tickets sold)

10) Display current theatre finances (current ticket sales and payroll for the next month)

11) Hire a theatre staff member or theatre manager

12) Pay a theatre staff member / manager

13) Remove a theatre staff member / manager

14) Have an investor support a play at the theatre (put money in the theatre bank acct)

15) Modify values for hourly pay and hours worked for all persons

16) Modify ticket prices for a specific show

17) Display a bank account for any person or the theater or the rental company

18)   For any action which adds/hires a person, use a person GUI with a menu to select person type, buttons for any boolean values, limited possible inputs

            for numeric day values,  month values selected from a list of month names and then panels  which capture other data for the appropriate type of

            person being added (ex. the Actor panel would include a place to enter the role but the Director panel would include the percentage of the house

that they receive.)  This applies to actions 3 and 11 above and applies to any other persons (attendees and investors) if they can be added.

0) Exit program

 

A. The Theater class should contain the following data and methods:

Data members:

1. Has a name

2. Has a current play showing on multiple dates and days (has list of multiple shows)

3. Has different prices for different show days

3.a. Friday and Saturday night price

3.b. Saturday and Sunday matinee price (a percentage of the Fri/Sat night price)

3.c. Sunday night price (a different percentage of the Fri/Sat night price)

4. Has a number of seats in the theatre

            4.a. Number of regular seats

            4.b. Number of box seats

5. Has a maximum yearly operating budget

6. Keep track of rented items for show (using a collection class)

7. Has a bank account for its operating budget

8. Has a list of staff and a payroll

 

 

Methods:

a. Sells tickets to a show

b. Accepts payments from attendees

c. Keeps track of how many tickets have been sold

d. Refunds ticket payments

e. Keeps track of sales of tickets as a monetary total

f.  Pays employees (theatre staff, manager, actors, director)

g. Hires and fires employees

h. Keeps track of how many actors/directors are currently working on a given play

i. Pays actors/directors at the end of each week, adjusting the operating budget as necessary

j.  Pays theatre staff and manager at end of each month, adjusting the operating budget as necessary

k. Displays all plays, actors, attendees, etc. in a tabular formatted manner

 

B. The Play class has the following features          EXAMPLE

1. Title                                                                                    Cabaret

2. Author                                                                    Jay Allen

3. Year published                                                      1972

4. Opening date                                                         March 31, 2014

5. World premier                                                      boolean

6. Play usage rental                                                  $8400.00

7. End date                                                                April 15, 2014

(Use Java Date class from java.util.Date)

8. Total number of shows                                        11

9. List of actors

10.  Director

 

 

The Show class has

1. Date (day, month, year)

2. Day of the week

3. Time of the show (night or matinee or special)

4. Has a number of seats per show

            4.a. Regular seat cost (based on show day price)

            4.b. Box seat ticket cost (a percentage over the show day price)

5. Has a list of tickets sold (one ticket per seat)

6. The play being shown

 

 

C. The Person class has the following attributes   EXAMPLE

1. First name                                                              Jaya

2. Last name                                                              Smith

3. Identification number                                          006

4. Address                                                                  123 Sesame St., NY, NY 10001

5. Birthdate                                                                July 4, 1963

6. Hire date                                                                November 1, 2012

7. Bank account                                                         from BankAccount class

 

 

The Actor class has the following attributes          EXAMPLE

Inherits data fields from person class

5. Hired for which play                                             Cabaret

6. Pay scale per hour                                                            $12.00

7. Actor's Equity?                                                      boolean

8. Role                                                                         Character name

9. Hours worked per week                                       15

 

The method for CalculatePay for an actor is to pass in the pay scale per hour, the hours worked for week, and a 1 if the Actor's Equity boolean is true or 0 if false.  The pay is then calculated one of two ways based on the boolean value. 

If the Actor's Equity boolean was false then the

actor's pay equals pay per hour * hours per week

If the Actor's Equity boolean was true then the pay calculation is:

actor's pay equals pay per hour * hours per week PLUS

            the greater of ((hours per week – 40) * pay per hour)  OR 0 (zero)

[ Basically, there is extra pay for over 40 hours a week if the actor is part of Equity]

 

 

The Director class has the following attributes                 EXAMPLE

Inherits data fields from person class

5. Hired for which play                                             Cabaret

6. Pay scale per hour                                                            $30.00

7. Actor's Equity?                                                      boolean

8.  Up front fee                                                          $450.00

9.  Percentage of house                                            15%

10.  Hours worked per week                                   50

 

The method for CalculatePay for a director is to pass in the up front fee, the pay scale per hour, and a 1 if the Actor's Equity boolean is true or 0 if false.  The pay is then calculated one of two ways based on the boolean value. 

If the Actor's Equity boolean was false then the

actor's pay equals up front fee

If the Actor's Equity boolean was true then the pay calculation is:

actor's pay equals up front fee PLUS

            the greater of ((hours per week – 40) * pay per hour)  OR 0 (zero)

[ There is extra pay for over 40 hours a week if the director is part of Equity]

 

Directors will also have a method for PerformancePay which will be based on the total ticket sales for all shows taking the gross revenue for ticket sales and determining 15% of the gross revenue.  This percentage of the house is the pay the director receives for the complete run of the play and all performances.

 

 

The Attendee class has the following attributes   EXAMPLE

Inherits data fields from person class

5. Attending which play                                           Cabaret

6. Ticket price category                                            $20.00

7.Number of tickets                                                  integer

8. Date of tickets                                                        March 19, 2014

9. Which show? (Eve or matinee)                           (use an enum here)

 

 

The theater Staff member class has the following attributes     

Inherits data fields from person class

5. Work position                                USHER (enum with TICKETSELLER, CONCESSIONS)

6. Pay scale per hour                                    $8.25

7. Hours worked per week               22

8. Days worked each week               THURSDAY, SATURDAY  (enum type of all days)

9. Number of weeks worked this month    4.5  (one extra Thursday worked)

 

The method for CalculatePay for a theater staff member is to pass in the pay scale per hour, the hours worked for week, and a number of weeks worked in the current month.  The theatre staff member's pay monthly pay is : 

pay per hour * hours per week * weeks worked in current month

 

 

The theater Manager class has the following attributes

Inherits data fields from person class

5. Number of staff members                       14

6. Weekly pay rate                            $800.00

7. Vacation weeks taken in month 1  (this will often be 0)

8. Days worked each week               THURSDAY, FRIDAY, SUNDAY  (enum type of all days)

9. Total weeks in this month            4.5  (indicates 31 days in month)

 

The method for CalculatePay for a theater manger is to pass in the weekly pay rate, the number of vacation weeks taken in the month and the total number of weeks in the current month.  The manager pay is then : 

 weekly pay rate * (total weeks in month – vacation weeks taken in month)

 

 

The Investor class has the following attributes    

Inherits data fields from person class

5. Amount invested                           double

6. Tickets received                            int

7. Percentage of house                     percentage

 

 

D.  Interface for CalculatePay as

double CalculatePay(double Amt1, double Amt2, double Amt3);

 

E.  Class for BankAccount has the following attributes:

1.  Current total                                                         double

2.  List of last three payment transactions made

3.  List of last three deposit transactions received

4.  Receiving direct deposit?                                                Boolean

5.  Account number

 

Class for AccountTransaction

1.  Payee                                                         object of Theater or Person class

2.  Payer                                                         object of Theater or Person class

3.  Amount                                                     double

4.  Reason                                                       String "ticket sale", "weekly pay", etc.

 


Program Requirements

For Lab #4 you should

1)   define classes for all the described elements above,

2)   use inheritance to create at least three of the classes,

3)   use Bank Account and AccountTransaction to handle money transactions,

4)   create a ticket class which includes a price, a date, time, and seat number

5)   keep data members private unless otherwise instructed

6)   create get and set methods for all private data members

7)   create toString and/or display methods for all classes (other than the test class)

8)   create constructors and initialize objects as needed

9)   read initial data in from a input file (using a Scanner object connected to the file)

10)          output information to the user in GUI windows

11)          Use Javadoc commands to comment your code and generate the Javadoc documentation to submit with the assignment

12) use a GUI as described earlier to enter new person data

13) demonstrate changes in bank accounts after various transactions

14) use the input data files WITHOUT removing comments – this means your code must handle comment markers.

 

Java provides mechanisms for comments and input for Javadoc. Please make sure your code contains both. Also, submit the files generated by the Javadoc for your program. Look up the convention for specifying parameters (@param) and user information for javadoc. Every method should have its meaningful description for use by someone else. Use the relevant Javadoc tags specified in -http://en.wikipedia.org/wiki/Javadoc or http://java.sun.com/j2se/javadoc/writingdoccomments/

 

 


Standard Java conventions and coding style:

Be sure to observe standard Java naming conventions and style. These will be observed across all projects for this course, hence it is necessary that you understand and follow them correctly. They include:

á      Class names begin with an upper-case letter, as do any subsequent words in the class name.

á      Method names begin with a lower-case letter, and any subsequent words in the method name begin with an upper-case letter.   This is called "camelCase".

á      Class, instance and local variables begin with a lower-case letter, and any subsequent words in the name of that variable begin with an upper-case letter.

á      Each set of opening/closing curly braces must be in the same column.

á      All user prompts must be clear and understandable

á      Give meaningful names for classes, methods, and variables even if they seem to be long. The point is that the names should be easy to understand for a person looking at your code

á      All static final variables will be upper case identifiers (i.e.constants)

á      One class per file

 

In addition, ensure that your code is properly documented in terms of comments and other forms of documentation wherever necessary.

 

 


What and How to Submit

For Lab #4 WRITE A JAVADOC DESIGN DOCUMENT FIRST.  The design must be written as Javadoc code giving:

 

      a) all the classes you expect to write,

 

      b) brief (one line) descriptions of each data member of the class

 

      c) brief (one line) descriptions of each method (member function) of the class, and

 

      d) some indication of the relationships between the classes.

 

The design document must be written using Javadoc notation.  This design document will be the documentation incorporated into the lab assignment.

 

Each class should encapsulate one thing and each piece of data at a lower level should have a more specific purpose than the class that owns it.  Be sure to include all the classes that are described in this lab assignment. 

 

See the website or this assignment for the DESIGN DOCUMENT due date.  It is usually ONE WEEK PRIOR to the lab due date.

 

A Lab #4 Design Document must be turned in in order for your Lab #4 assignment to be graded.

 

 

For this lab project itself, please submit the following material using the Blackboard system at elearn.uta.edu. Please submit ONE .zip file that contains:

á      Each .java file used in development with the appropriate name for the included class

á      A document, called your "test plan", listing each test case that is in your test class and what the purpose is of each test (Note that the grading rubric requires at least two tests per each of the required 17(or 18) functions above)

á      The Javadoc design document from your program

á      A development notes file (standard text or word file) that describes at least one error that you found while developing your code, how you solved it, and the total amount of time you spent on this project in terms of hours.

 

The .zip file containing your project must have the name format of: proj4_1000number_firstname_lastname

Upload this code to Blackboard at elearn.uta.edu

 

A Few Helpful Tips:

á      Netbeans by default recompiles your class every time you save your file. If you want to force everything to be recompiled, press the Ôclean and buildÕ button.

á      Ctrl + space in most IDEÕs will show a list of available members (or variables) and methods (or functions).

 

 

Grading Rubric:

Code:  (35%)

      Headers, comments, style and modularity                                           (15 points)

            This must be done with Javadoc for Lab #4.  Class header and method headers for all classes, Comments (line comments and block comments), Style (following Java conventions, indentation, consistency, meaningful identifiers, lateral separation of code from line comments, etc.), Modularity (division of the problem into small parts) 

      Correct declaration of the required classes with data and methods and any other needed classes  including all modifications and new classes                                                                                                          (5 points)

      Correct interface definition                                                                          (7points)

      Test plan includes at least two tests for each of the required

            17 ( or 18) functions  and uses the

            display functions to verify test reults                                                (8 points)

     

Output:    (65%)

      GUI input works correctly                                                                                (10 pts)

      File input works correctly  with comments in file                                    (7 pts)

 

      User clearly understands what is being requested for input            (3 points)

      All required tasks perform correctly   including new tasks              (8 points)

 

      Get , Set, toString functions and interfaces implemented correctly     (8 pts)

 

      Graphical user interfaces implemented as required for output              (5 pts)

      Javadoc elements demonstrate design and work correctly               (5 points)

      Output gives clear information to explain the values to the user     (3 points)

      Output contains at least three data sets,                                                   (9 points)

      Output demonstrates all elements of test plan                                        (7 points)

 

Grading Deductions:

      Labs which do not compile in NetBeans will receive an overall grade of 0 (zero) [-100 deduction]

      Labs which have errors in them and do not terminate normally in NetBeans will receive an overall grade of 0 (zero) [-100 deduction]

      Late submission of softcopy of design document, code and/or other documents to Blackboard will result in an overall grade of 0 (zero) UNLESS student has obtained prior instructor approval [-100 deduction]

      Use of Java language elements not yet discussed in class by the lab due date will result in potential deduction of points - discuss with instructor before using.

      Use of Java public variables (C equivalent to global variables) will result in an overall grade of 0 (zero) [-100 deduction]

      Use of unstructured control elements, like the break (except in the case of switch statements), continue, or exit keywords, will result in an overall grade of 0 (zero) [-100 deduction]

 

Miscellaneous:  If you have questions, e-mail Dr. T (tiernan@uta.edu) and the TA.